package cn.yunhe.servlet;

import cn.yunhe.bean.Comment;
import cn.yunhe.biz.CommentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
@WebServlet("/getHotelCommentServlet")
public class getHotelCommentServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        int hotelid = (int) session.getAttribute("hotelid");
        CommentService commentService =new CommentService();
        List<Comment> commentList= commentService.getHotelCommentById(hotelid);
        req.setAttribute("commentList",commentList);
        if(commentList!=null&&commentList.size()>0){
            req.getRequestDispatcher("singleHotel.jsp").forward(req,resp);
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
